<div class="page-header">
    <h1>New Post</h1>
</div>

<form role="form" ng-submit="save()" name="postForm" novalidate>

    <div class="form-group" ng-class="{'has-error':postForm.title.$invalid && postForm.title.$touched}">
        <label class="control-label" for="title">{{'title'|translate}}</label>

        <input name="title" class="form-control" type="text"
               placeholder="Post title" ng-model="newPost.title" ng-required="true"></input>
        <div class="help-block" ng-messages="postForm.title.$error" ng-if="postForm.title.$touched">
            <p ng-message="required">Post title is required.</p>
        </div>
    </div>

    <div class="form-group" ng-class="{'has-error':postForm.content.$invalid && postForm.content.$touched}">
        <label class="control-label" for="content">{{'content'|translate}}</label>
        <textarea name="content" class="form-control" type="text"
                  placeholder="Post conent" ng-model="newPost.content" rows="8" ng-required="true" ng-minlength="15"></textarea>
        <div class="help-block" ng-messages="postForm.content.$error" ng-if="postForm.content.$touched">
            <p ng-message="required">Post content is required.</p>
            <p ng-message="minlength">At least 15 chars.</p>
        </div>
    </div>

    <div class="form-group">
        <button type="submit" ng-disabled="postForm.$invalid" class="btn btn-primary btn-lg">
            {{'save'|translate}}
        </button>
        <button type="button" ng-click="cancel()" class="btn btn-default btn-lg">
            {{'cancel'|translate}}
        </button>
    </div>
</form>
